public class Rate {
    int a;//贷款总额
    int m;//贷款月数
    double n;//贷款年利率
    double benjin;
    double benxi;
    Rate(int a, int m, double n){
        this.a = a;
        this.m = m;
        this.n = n;
    }

    double BenJin(){
        benjin = ((m+1)*a*(n/12)) / 2;
        System.out.println("等额本金还款法"+benjin);
        return benjin;
    }

    double Benxi(){
        double mi = Math.pow((1 + n/12),m);
        benxi = m*a*n/12*mi / (mi-1) - a;
        System.out.println("等额本息还款法"+benxi);
        return benxi;
    }
}